/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.vivo.dealer.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.TreeEntity;

/**
 * 商品类别Entity
 * @author jyangye
 * @version 2017-11-07
 */
public class VivoWaresKind extends TreeEntity<VivoWaresKind> {
	
	private static final long serialVersionUID = 1L;
	private VivoWaresKind parent;		// 父编号
	private String parentIds;		// 所有父编号
	private String kind;		// 所属大类(商品类、配件类、。。。)
	private String code;		// 商品类别编号
	private String name;		// 商品类别名称
	private String propertyId;		// 类别属性
	
	public VivoWaresKind() {
		super();
	}

	public VivoWaresKind(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="父编号不能为空")
	public VivoWaresKind getParent() {
		return parent;
	}

	public void setParent(VivoWaresKind parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=2000, message="所有父编号长度必须介于 1 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=0, max=2, message="所属大类(商品类、配件类、。。。)长度必须介于 0 和 2 之间")
	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}
	
	@Length(min=0, max=20, message="商品类别编号长度必须介于 0 和 20 之间")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	@Length(min=1, max=50, message="商品类别名称长度必须介于 1 和 50 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=0, max=32, message="类别属性长度必须介于 0 和 32 之间")
	public String getPropertyId() {
		return propertyId;
	}

	public void setPropertyId(String propertyId) {
		this.propertyId = propertyId;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}